<?php

namespace App\Http\Requests\V3_2_7;

use Illuminate\Foundation\Http\FormRequest;

class AbsenceRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'start_time'=>'required|date_format:Y-m-d',
            'end_time'=>'required|date_format:Y-m-d',
            'rest_days'=>'required|integer',
            'reason_applying'=>'nullable|max:300'
        ];
    }

    /**
     * 验证错误信息.
     *
     * @return array
     */
    public function messages(): array
    {
        return [
            'start_time.required' => '申情开始时间,不能为空',
            'set_time.date_format' => '申情开始格式错误，如：2024-08-01',
            'end_time.required' => '申情结束时间,不能为空',
            'end_time.date_format' => '申情结束时间格式错误，如：2024-08-03',
            'rest_days.required' => '休息天数,不能为空',
            'rest_days.integer' => '休息天数,为整数！',
            'reason_applying.max' => '申请原因不能超过300个字符！',
        ];
    }
}
